package com.server.questionbank.snframe.mapper.Course;

import com.server.questionbank.snframe.domain.Course.CourseComment;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface CourseCommentMapper {
    @Select("select * from course_comment where comment_id=#{commentId}")
    public CourseComment selectCourseCommentById(Long commentId);
    @Select("select * from course_comment where course_id= #{courseId} and (parent_id = null or parent_id = 0)")
    public List<CourseComment> selectCourseCommentByCourseId(Long courseId);
    @Select("select * from course_comment where parent_id = #{parentId}")
    public List<CourseComment> selectCourseCommentByParentId(Long parentId);
    @Insert("insert into course_comment(" +
            "course_id,user_id,parent_id,content,score" +
            ") values(" +
            "#{courseId},#{userId},#{parentId},#{content},#{score}" +
            ")")
    public Integer insertCourseComment(CourseComment courseComment);

    @Delete("delete from course_comment where comment_id=#{commentId}")
    public Integer deleteCourseComment(Long commentId);
}
